<?php
/**
 * Pes for PHP 5.3+
 *
 * Copyright (c) 2013 phpeskill.com (http://www.pescms.com)
 *
 * For the full copyright and license information, please view
 * the file LICENSE.md that was distributed with this source code.
 */
namespace Model\Admin;

/**
 * 用户组模型
 * @author LazyPHP
 * @version 1.0
 */
class GroupModel extends CommonModel {
    
    /**
     * 获取用户组信息
     * @param type $value 查找的值
     * @param type $type 查找的类型|默认为ID
     * @return boolean 提交参数为空时，返回二维数组。参数不为空则返回一维数组。没有结果则返回false;
     */
    public static function getGroup($value="", $type="id"){
        return self::GetTableContent($value, $type, 'user_group');
    }
    
    /**
     * 获取用户组下拉表单
     * @param type $id 用户组ID:判断是否选中状态
     * @return string 返回设置好的表单
     */
    public static function getSelectGroup($id = ''){
        $list = self::getGroup();
        $str = '';
        foreach($list as $key => $value){
            if($id == $value['id']){
                $str .= '<option value="'.$value['id'].'" selected="selected">'.$value['name'].'</option>';
            }else{
                $str .= '<option value="'.$value['id'].'">'.$value['name'].'</option>';
            }
        }
        return $str;
    }
    
}